﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Casemeet.Groups;
using VK.Comm;

namespace VK.Casemeet.Web.ShopAdmin.Groups
{
    public partial class CategoryAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            (this.Master as Site).SiteMapPathControl.MapPathList = new List<MapPath>(){
                new MapPath{ Text="桌面",Url="/ShopAdmin/Home.aspx"},
                new MapPath{ Text="商品",Url="CategoryList.aspx"},
                new MapPath{ Text="新建分类",Url="#"}
            };

        }

        protected void butSave_Click(object sender, EventArgs e)
        {
            CategoryEntity category = LoadEntity();

            if (GroupsBLL.AddGroupCategory(category) > 0)
            {
                Message.Msg(this.Page, CS.MsgAddSuccess, MessageType.Success);
                Util.ClearControl((this.Master as Site).contentBody.Controls);
            }
            else
            {
                Message.Msg(this.Page, CS.MsgAddFailure, MessageType.Failure);
            }
        }

        protected CategoryEntity LoadEntity()
        {
            CategoryEntity category = new CategoryEntity();
            category.gc_name = txtName.Text;
            category.gc_isenable = chkIsEnable.Checked;
            return category;
        }
    }
}